//
//  TaskMerchantTableViewCell.m
//  BaishidaiKnight
//
//  Created by mac book on 2019/1/28.
//  Copyright © 2019年 sy. All rights reserved.
//

#import "TaskMerchantTableViewCell.h"

@interface TaskMerchantTableViewCell ()


@property(nonatomic,strong) UIImageView* shopImageView;
@property(nonatomic,strong) UILabel* shopTitleLabel;
@property(nonatomic,strong) UILabel* shopPriceLabel;


@end



@implementation TaskMerchantTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        
        [self createSubviews];
        
    }
    return self;
}

#pragma mark - createSubviews
-(void)createSubviews{
    
    [self.contentView addSubview:self.shopImageView];
    [self.contentView addSubview:self.shopTitleLabel];
    [self.contentView addSubview:self.shopPriceLabel];
    
    [self.shopImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.equalTo(self.contentView);
        make.left.equalTo(self.contentView).offset(10);
        make.size.mas_equalTo(CGSizeMake(70, 70));
        
    }];
    
    [self.shopTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.shopImageView);
        make.left.equalTo(self.shopImageView.mas_right).offset(10);
        make.right.equalTo(self.contentView);
        make.height.mas_equalTo(30);
        
    }];
    
    [self.shopPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.shopImageView);
        make.left.right.equalTo(self.shopTitleLabel);
        make.height.mas_equalTo(30);
        
    }];
    
    
    
    
}


-(void)setTaskModel:(TaskModel *)taskModel{
    
    _taskModel = taskModel;
    
    [_shopImageView sd_setImageWithURL:[NSURL URLWithString:taskModel.goods_img] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    
    _shopTitleLabel.text = taskModel.fname;
    
    _shopPriceLabel.text = [NSString stringWithFormat:@"%@ ✖️ %@",taskModel.price,taskModel.quantity];

    
}
-(UIImageView *)shopImageView{
    
    if (!_shopImageView) {
        _shopImageView = [[UIImageView alloc] init];
        _shopImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
    
    return _shopImageView;
}

-(UILabel *)shopTitleLabel{
    if(!_shopTitleLabel){
        _shopTitleLabel = [[UILabel alloc]init];
        _shopTitleLabel.textColor =kMyColor(130, 130, 130);
        _shopTitleLabel.font = kFontNameSize(17);
    }
    return _shopTitleLabel;
}


-(UILabel *)shopPriceLabel{
    if(!_shopPriceLabel){
        _shopPriceLabel = [[UILabel alloc]init];
        _shopPriceLabel.textColor =kMyColor(130, 130, 130);
        _shopPriceLabel.font = kFontNameSize(15);
    }
    return _shopPriceLabel;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
